package Server;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.codehaus.jettison.json.JSONObject;

import Server.BusinessObjects.Scenario;

@Path("/scenarios")
public class ScenarioResource {
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public String getScenarios() {

		List<JSONObject> objects = new ArrayList<JSONObject>();
		try {
			List<Scenario> scenarios = Scenario.getScenarios();
			
			for(Scenario s : scenarios) {
			JSONObject o = new JSONObject();
			o.put("Id", s.getId());
			o.put("Name", s.getName());

			objects.add(o);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return objects.toString();
	}
	
}
